using System;
using System.ComponentModel.DataAnnotations;
using InfoTech.VinhSon.Bussiness;

namespace InfoTech.VinhSon.Models
{
	[Serializable]
	public partial class ArticleModel
	{

		#region Constructor

		public ArticleModel()
		{
		}

		public ArticleModel(Article value)
		{
			Id = value.Id;
			if(value.Category != null)
				CategoryId = value.Category.Id;
			Name = value.Name;
			Description = value.Description;
			Thumbnail = value.Thumbnail;
			Detail = value.Detail;
			Activated = value.Activated ?? false;
			Link = value.Link;
			Url = value.Url;
			Status = value.Status;
		}

		#endregion

		#region Fields

		private System.Int32 _Id;

		private System.Int32? _CategoryId;

		private System.String _Name;

		private System.String _Description;

		private System.String _Thumbnail;

		private System.String _Detail;

		private System.Boolean _Activated;

		private System.String _Link;

		private System.String _Url;

		private System.Int32? _Status;

		#endregion

		#region Properties

		//[Required]
		//[Range(0, 0]
		//[StringLength(0)]
		public System.Int32 Id
		{
			get
			{
				return _Id;
			}
			set
			{
				_Id = value;
			}
		}

		//[Required]
		//[Range(0, 0]
		//[StringLength(0)]
		public System.Int32? CategoryId
		{
			get
			{
				return _CategoryId;
			}
			set
			{
				_CategoryId = value;
			}
		}

		//[Required]
		//[Range(0, 0]
		[StringLength(200)]
		public System.String Name
		{
			get
			{
				return _Name;
			}
			set
			{
				_Name = value;
			}
		}

		//[Required]
		//[Range(0, 0]
		[StringLength(1073741823)]
		public System.String Description
		{
			get
			{
				return _Description;
			}
			set
			{
				_Description = value;
			}
		}

		//[Required]
		//[Range(0, 0]
		[StringLength(255)]
		public System.String Thumbnail
		{
			get
			{
				return _Thumbnail;
			}
			set
			{
				_Thumbnail = value;
			}
		}

		//[Required]
		//[Range(0, 0]
		[StringLength(1073741823)]
		public System.String Detail
		{
			get
			{
				return _Detail;
			}
			set
			{
				_Detail = value;
			}
		}

		//[Required]
		//[Range(0, 0]
		//[StringLength(0)]
		public System.Boolean Activated
		{
			get
			{
				return _Activated;
			}
			set
			{
				_Activated = value;
			}
		}

		//[Required]
		//[Range(0, 0]
		[StringLength(1000)]
		public System.String Link
		{
			get
			{
				return _Link;
			}
			set
			{
				_Link = value;
			}
		}

		//[Required]
		//[Range(0, 0]
		[StringLength(200)]
		public System.String Url
		{
			get
			{
				return _Url;
			}
			set
			{
				_Url = value;
			}
		}

		//[Required]
		//[Range(0, 0]
		//[StringLength(0)]
		public System.Int32? Status
		{
			get
			{
				return _Status;
			}
			set
			{
				_Status = value;
			}
		}

		#endregion

		#region Operators

		public void Update(Article value)
		{
			// value.Id = Id;
			value.Name = Name;
			value.Description = Description;
            //value.Thumbnail = Thumbnail;
			value.Detail = Detail;
			value.Activated = Activated;
			value.Link = Link;
            //value.Url = Url;
            //value.Status = Status;
		}

		public static implicit operator ArticleModel(Article obj)
		{
			return new ArticleModel(obj);
		}

		public static implicit operator Article(ArticleModel obj)
		{
			Article value = new Article();
			obj.Update(value);
			return value;
		}

		#endregion

	}
}
